<template>
  <div class="b-fan" :title="name">
    <div class="fan-container">
      <div class="air-flow"></div>
      <div class="fan-frame" :class="{ 'fan-rotating': status === '开' }">
        <div class="blade"></div>
        <div class="blade"></div>
        <div class="blade"></div>
        <div class="fan-center"></div>
      </div>
    </div>
    <div class="name">
      {{ name }}
    </div>
  </div>
</template>
<script setup lang='ts'>

defineProps({
  status: {
    type: String,
    default: '关' // 0 关 1 开
  },
  name: {
    type: String,
    default: ''
  }
})



</script>
<style lang="scss" scoped>
.b-fan {
  display: flex;
  justify-content: center;
  position: relative;
  width: 40px;
  height: 40px;
}

.fan-container {
  position: relative;
  width: 30px;
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.name {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fan-frame {
  position: absolute;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background: radial-gradient(circle, #555 0%, #333 70%, #222 100%);
  border: 4px solid #444;
  box-shadow:
    0 0 25px rgba(0, 0, 0, 0.8),
    inset 0 0 15px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

/* 中心圆 */
.fan-center {
  width: 30%;
  height: 30%;
  background: radial-gradient(circle, #ddd 0%, #aaa 100%);
  border-radius: 50%;
  border: 2px solid #777;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  z-index: 20;
}

/* 风扇叶片 */
.blade {
  position: absolute;
  width: 15%;
  height: 50%;
  background: linear-gradient(to bottom, #e0e0e0, #a0a0a0);
  border-radius: 50% 50% 10% 10%;
  transform-origin: bottom center;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.blade:nth-child(1) {
  transform: translateY(-50%) rotate(0deg);
}

.blade:nth-child(2) {
  transform: translateY(-50%) rotate(120deg);
}

.blade:nth-child(3) {
  transform: translateY(-50%) rotate(240deg);
}

/* 风扇旋转动画 */
.fan-rotating {
  border-color: var(--el-color-primary-light-5);
  animation: rotate 1.5s linear infinite;
}

@keyframes rotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* 气流效果 */
.air-flow {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  opacity: 0.7;
  z-index: 5;
}

.air-flow::before,
.air-flow::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid rgba(200, 230, 255, 0.8);
  box-shadow: 0 0 15px rgba(173, 216, 230, 0.6);
  box-sizing: border-box;
  animation: pulse 2s ease-out infinite;
}

.air-flow::after {
  animation-delay: 1s;
}

@keyframes pulse {
  0% {
    transform: scale(0.5);
    opacity: 0.8;
  }

  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}
</style>
